home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 15786 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  824 b 

  1. Path: news-m01.ny.us.ibm.net!usenet
  2. From: bbogard@ibm.net
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Operator Overloading
  5. Date: 8 Apr 1996 02:18:42 GMT
  6. Message-ID: <4k9t22$173k@news-s01.ny.us.ibm.net>
  7. References: <9604071905.AA001o6@lorelei.demon.co.uk>
  8. Reply-To: bbogard@ibm.net
  9. NNTP-Posting-Host: slip129-37-223-75.ca.us.ibm.net
  10. X-Newsreader: IBM NewsReader/2 v1.2.5
  11.  
  12. >and it seems to allow me to say
  13. >
  14. >       double x;
  15. >
  16. >       x = MyClass;
  17. >
  18. >It seems to be a user-defined casting operator, but I can't find any
  19. >mention of this in any books I have.  Can anyone explain what I have
  20. >discovered here?
  21. What you have discovered is a conversion operator.  The compiler would use it to
  22. convert from one type of object to another.  That is why your compiler can assign
  23. MyClass to x.  It does it through the conversion operator.
  24.